home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / dcf77 / developer / waitfordcf77.c < prev    next >
C/C++ Source or Header  |  1997-02-19  |  1KB  |  57 lines

  1. /* WaitForDCF77                                                     ***RGR***
  2.                                                                     12-sep-94
  3.    Author:   Ralf Gruner, Großschönau, Germany.
  4.  
  5.              ralf.gruner@t-online.de
  6. */
  7.  
  8. #include <exec/types.h>
  9. #include <exec/semaphores.h>
  10. #include <clib/exec_protos.h>
  11. #include <clib/dos_protos.h>
  12. #include <stdio.h>
  13.  
  14. struct StatusList
  15. {
  16.     struct SignalSemaphore sl_Semaphore;
  17.     STRPTR version;
  18.     BOOL Received;
  19. };
  20.  
  21. struct StatusList *DCF77PublicStatus=NULL;
  22.  
  23. UBYTE    * DCF77SemaphoreName = "DCF77 State";
  24. BOOL    DCF77received=FALSE;
  25.  
  26. main(int argc, char *argv[])
  27. {
  28.     char *msg1="\n WaitForDCF77 Version 1.01 - © 1994 Ralf Gruner, Großschönau, Germany.\n";
  29.     char *msg2=" WaitForDCF77 waits for received time from the\n european radio clock signal DCF77.";
  30.     char *msg3=" Usage: Simply run it while the receiver software DCF77 is running.\n";
  31.  
  32.     if(argc != 1)
  33.     {
  34.         puts(msg1);
  35.         puts(msg2);
  36.         puts(msg3);
  37.     }
  38.     else
  39.         while(!DCF77received)
  40.         {
  41.             Forbid();
  42.             if(DCF77PublicStatus=(struct StatusList *) FindSemaphore(DCF77SemaphoreName))
  43.             {
  44.                 ObtainSemaphoreShared((struct SignalSemaphore *) DCF77PublicStatus);
  45.                 DCF77received=DCF77PublicStatus->Received;
  46.                 ReleaseSemaphore((struct SignalSemaphore *) DCF77PublicStatus);
  47.             }
  48.             else
  49.                 DCF77received=FALSE;    // DCF77 is not running
  50.             Permit();
  51.  
  52.             if(!DCF77received)
  53.                 Delay(150L);    // wait three seconds and try again...
  54.         }
  55. }
  56.  
  57.